<%@ taglib prefix="page" uri="http://com.qipay/pagelib" %>
<%@ page language="java" import="com.qipay.admin.cp.vo.CpPostDTO" contentType="text/html;charset=utf-8" %>
<%@ page import="com.qipay.security.UserDetailsServiceImpl" %>
<%@ page import="com.qipay.user.entity.UserLevel" %>
<%@ page import="com.qipay.baas.model.CpChannel" %>
<%@ page import="com.qipay.admin.utils.SiteHelper" %>
<%@ page import="com.qipay.baas.model.CpInfo" %>
<%@ page import="com.qipay.baas.model.SpApiConfig" %>
<%@ page import="com.qipay.baas.model.ApiType" %>
<%@ page import="java.util.List" %>
<%@ page import="com.qipay.scalar.type.ChannelTypeEnum" %>
<%@ page import="com.qipay.scalar.type.ApiTypeEnum" %>
<!doctype html>
<html>
<head>
    <jsp:include page="head.jsp"></jsp:include>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <% SpApiConfig cpChannel = (SpApiConfig)request.getAttribute("detail");
           boolean isAdd = String.valueOf(request.getAttribute("isadd")).equals("1");

        %>
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <h3 class="box-title">编辑sp_api_config配置</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <form class="form-horizontal" action="save" method="POST" id="doc-vld-msg">
                            <input type="hidden" name="spId" value="<%= isAdd?request.getParameter("spid"):cpChannel.getSpId()%>">
                            <input type="hidden" name="id" value="<%= isAdd?"":String.valueOf(cpChannel.getId())%>">
                            <div class="box-body" id="dvContent">

                                <div class="form-group">
                                    <label for="ddltype" class="col-sm-2 control-label">支付方式：</label>
                                    <div class="col-sm-10">
                                        <select id="ddltype" name="channelType">
                                            <% for (ChannelTypeEnum channelType: ChannelTypeEnum.values()) {%>
                                            <option value="<%= channelType.getType()%>"><%= channelType.getInfo()%>
                                            </option>
                                            <%}%>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group" style="<%= isAdd?"":"display:none"%>">
                                    <label for="ddlapiType" class="col-sm-2 control-label">对应API值：</label>
                                    <div class="col-sm-10">
                                        <select id="ddlapiType" name="apiType">
                                            <%  for(ApiTypeEnum apiType:ApiTypeEnum.values()){%>
                                            <option value="<%= apiType.getType()%>"><%= apiType.getInfo()%></option>
                                            <%}%>

                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtkey" class="col-sm-2 control-label">KEY：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtkey" name="key" mush="1"
                                               value="<%= isAdd?"":cpChannel.getKey()%>" placeholder="配置的KEY值">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtValue" class="col-sm-2 control-label">Value：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtValue" name="val" mush="1"
                                               value="<%= isAdd?"":cpChannel.getVal()%>" placeholder="配置的Value值">
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer">
                                <button type="button" class="button back-green" onclick="window.history.back()">返回
                                </button>
                                <button type="button" class="button back-green" id="btnSearch">确 定</button>
                            </div>
                            <!-- /.box-footer -->
                        </form>
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <jsp:include page="foot.jsp"></jsp:include>
</div>
<script src="<%= request.getAttribute("StaticHost") %>/js/fastclick.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>
<script>
    $(function () {
        var currentType = '<%= request.getAttribute("isadd")%>',currentApiType = 0;
        if (currentType == "1") {
            currentType ="1";
        }
        else {
            currentType = "<%= cpChannel !=null&&cpChannel.getChannelType()!=null?cpChannel.getChannelType().byteValue():1%>";
            currentApiType = "<%= cpChannel !=null&&cpChannel.getApiType()!=null?cpChannel.getApiType().intValue():0%>";
            $("#ddlapiType").val(currentApiType);
        }
        if (currentType > 0) {
            $("#ddltype").val(currentType);
        }
        ddlapiType
        $("#btnSearch").on("click", function () {
            var isGo = checkInputMust("dvContent");
            if(isGo) {
                $("#doc-vld-msg")[0].submit();
            }
        });

    });

</script>
</body>
</html>

